<?php

class Outputs Extends CI_Controller
{
	public function __construct()
	{
		parent::__construct();
		$this->load->library('url_auth');
	}
	public function pged($id,$auth)
	{
		if($this->url_auth->val_auth($auth) AND is_numeric($id))
		{
			$this->load->model('M_employee','e');
			$result_set = $this->e->get_employee_attendance($id);
			
			if($result_set['status'] == 'true')
			{
				$data['profile'] = $this->e->one_employee($id);
				$data['employee'] = $result_set['employee_data'] ;
				
				$data['status'] = true;
			}else{
				$data['profile'] = $this->e->one_employee($id);
				$data['status'] = 'nodata';
			}
			$data['query'] = $result_set['last_query'];

			echo json_encode($data);
		}
		else{
			echo json_encode(array('status'=>'false'));
		}		
	}
	
	public function positions($id,$auth)
	{
		if($this->url_auth->val_auth($auth) AND is_numeric($id))
		{
			$this->load->model('M_position','e');
			$data = $this->e->get_positions_by_dept_id($id);
			
			if($data)
			{
				foreach($data as $v)
				{
					$options[$v->id] = $v->position_name;
				}
			}else{
				$options[''] = 'No Positions';
			}
			
			echo json_encode($options);

		}
		else{
			echo json_encode(array('status'=>'false'));
		}		
	}
}